/**
 * Copyright 2021 xpstem.com
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.xpstem.lelink.enums;

/**
 * value tool
 * @author billy zhang
 */
public class Value {

    private static final int POWER_POSITION_MAX = 100;
    private static final int POWER_NEGATION_MAX = -100;

    private static final int SPEED_POSITION_MAX = 100;
    private static final int SPEED_NEGATION_MAX = -100;

    private Value() { }

    public static int power(int value) {
        if (value > POWER_POSITION_MAX) {
            return POWER_POSITION_MAX;
        }
        if (value < POWER_NEGATION_MAX) {
            return POWER_NEGATION_MAX;
        }
        return value;
    }

    public static int speed(int value) {
        if (value > SPEED_POSITION_MAX) {
            return SPEED_POSITION_MAX;
        }
        if (value < SPEED_NEGATION_MAX) {
            return SPEED_NEGATION_MAX;
        }
        return value;
    }

}
